package com.demo.valuestream;

import com.demo.common.Dish;
import com.demo.common.DishUtil;

import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class TestMapToInt {
    public static void main(String[] args) {
        List<Dish> menu = DishUtil.getDishes();
        int calories = menu.stream()
                            .mapToInt(Dish::getCalories)
                            .sum();
        System.out.println(calories);

        IntStream intStream = menu.stream().mapToInt(Dish::getCalories); // 将Stream转换为数值流
        Stream<Integer> stream = intStream.boxed(); // 将数值流转换为Stream
    }
}
